package jodis.conn.impl;

import jodis.conn.inter.IReply;

import java.nio.charset.StandardCharsets;

import static jodis.JoConstants.CRLF;

public class IntReply implements IReply {
    private long code;

    public IntReply(long code) {
        this.code = code;
    }

    public static IntReply makeIntReply(long code) {
        return new IntReply(code);
    }

    @Override
    public byte[] toBytes() {
        // : + code + CRLF = 1 + 8 + 2 个字节
        StringBuilder builder = new StringBuilder(":");
        builder.append(code).append(CRLF);
//        return String.format(":%d%s", code, CRLF).getBytes(StandardCharsets.UTF_8);
        return builder.toString().getBytes(StandardCharsets.UTF_8);
    }
}
